/**********************************************
** @Des: This file ...
** @Author: xiaomeng79
** @Date:   17-12-21 下午2:08
***********************************************/
package libs

import (
	"net/smtp"
	"strings"
)

func SendEmail(username,sendTo,password,host,nickname,subject,body,port string) error {
	auth := smtp.PlainAuth("",username,password,host)
	to := strings.Split(strings.Replace(sendTo,"，",",",-1),",")
	//to := []string{"496096100@qq.com","mengqingfang@zingsq.cn"}
	user := username
	content_type := "Content-Type: text/html; charset=UTF-8"
	msg := []byte("To: " + strings.Join(to, ",") + "\r\nFrom: " + nickname +
		"<" + user + ">\r\nSubject: " + subject + "\r\n" + content_type + "\r\n\r\n" + body)

	return smtp.SendMail(host + ":"+port,auth,user,to,msg)
}